//
//  HeaderFocus.m
//  TheRoadAD
//
//  Created by baixue on 16/9/12.
//  Copyright © 2016年 baixue. All rights reserved.
//

#import "HeaderFocus.h"

@implementation HeaderFocus

#define TOPHEIGHT 50
#define titleBtn @[@"关注",@"粉丝",]


static int i;


-(id)initWithFrame:(CGRect)frame{
    if (self = [super initWithFrame:frame]) {
        //设置header 高度
        UIView *backView = [[UIView alloc] initWithFrame:CGRectMake(0, 0 , Screen_Width, 60 * Screen_Height/736)];
        backView.backgroundColor = [UIColor colorWithRed:0.96 green:0.96 blue:0.96 alpha:1];
        for (i = 0; i < 2; i++) {
            
            UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom];
            button.frame = CGRectMake(Screen_Width/2*i, 5, Screen_Width/2, 40);
            
            [button setTitle:titleBtn[i] forState:UIControlStateNormal];
            [button setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
            [button setBackgroundColor:[UIColor whiteColor]];
            button.titleLabel.font = [UIFont systemFontOfSize:14];
            [button addTarget:self action:@selector(buttonClicked:) forControlEvents:UIControlEventTouchUpInside];
            button.tag = 125+i;
            [backView addSubview:button];
            

        }
        UIView *line = [[UIView alloc] initWithFrame:CGRectMake(60 , 45, Screen_Width/2-120, 2)];
        _line = line;
        line.backgroundColor = [UIColor colorWithRed:0.35 green:0.85 blue:0.82 alpha:1];
        
        [backView addSubview:_line];
        [self addSubview:backView];
        
        
        //添加滑动视图
        _scrollerView = [[UIScrollView alloc] initWithFrame:CGRectMake(0, 60 * Screen_Height/736, Screen_Width, Screen_Height-64 - 60 * Screen_Height/736)];
        _scrollerView.contentSize = CGSizeMake(Screen_Width * 2, Screen_Height-64 - 60 * Screen_Height/736);
        _scrollerView.showsHorizontalScrollIndicator = NO;
        _scrollerView.backgroundColor = [UIColor whiteColor];
        _scrollerView.pagingEnabled = YES;
        [self addSubview:_scrollerView];
        UIView *lab = [[UIView alloc] initWithFrame:CGRectMake(Screen_Width/2 , 15, 2, 20)];
        
        lab.backgroundColor = [UIColor colorWithRed:0.35 green:0.85 blue:0.82 alpha:1];
        
        
        [backView addSubview:lab];
        
    }
    return self;
}

-(void)buttonClicked:(UIButton *)sender{
    
    NSInteger index = sender.tag;
    _SelectBlock(index);
    
}


@end
